import { defineReactive } from './utils.js'

export const observer = function (obj) {
  if (typeof obj !== 'object' && obj != null) {
    return
  }
  new Observer(obj)
}


export const Observer = class {
  constructor(obj) {
    this.$obj = obj
    // 是对象的时候的判断
    if (typeof obj == 'object') {
      this.walkObj(this.$obj)
    }
    // 是数组的时候的判断
    if(Array.isArray( obj)) {
      this.walkArr(obj)
    }
    // other
  }
  walkObj(obj) {
    Object.keys(obj).forEach(key => {
      defineReactive(obj, key, obj[key])
    });
  }
  walkArr() {
  }
}